/*
Date:20210529 21:42pm
key:1.用两个数组，一个是截至i的最小值,有点dp[i]=min(dp[i-1],newx)的意思，一个是普通栈。
*/
class MinStack {
public:
    int i=-1;
    int A[0xfff7]={0};
    int B[0xfff7]={0};
    int minp;
    /** initialize your data structure here. */
    MinStack() 
    {
        
    }
    
    void push(int x) 
    {
        //if(x<min){}
        i++;
        A[i]=x;
        if(i==0)
        {
            B[i]=x;
        }
        else
        {
            if(B[i-1]<x)
            {
                B[i]=B[i-1];
            }
            else{B[i]=x;}
            }
    }
    
    void pop() 
    {
        i--;
    }
    
    int top() 
    {
        return A[i];
    }
    
    int min() 
    {

        return B[i];
    }
};

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack* obj = new MinStack();
 * obj->push(x);
 * obj->pop();
 * int param_3 = obj->top();
 * int param_4 = obj->min();
 */